package org.example.config;

import org.example.bean.LubanUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//加载当前配置类的条件 必须存在2个属性 luban.user.name luban.user.enable=true
@ConditionalOnProperty(value="luban.user.name")
public class LubanUserAutoConfiguration {
    @Value("${luban.user.name}")
    private String name;
    @Bean
    @ConditionalOnProperty(value="luban.user.enable",havingValue = "true")
    public LubanUser lubanUser(){
        LubanUser lubanUser=new LubanUser(name);
        return lubanUser;
    }
}
